package agrpg.views;

import java.util.ArrayList;
import java.util.List;

import ag.AGContext;
import ag.AGEngine;
import ag.AGModelManager;
import ag.AGResource;
import ag.AGView;
import ag.rpg.AGRPGMap;
import ag.rpg.AGRPGObject;
import android.graphics.PointF;

public class TestMapView extends AGView {

	private List<AGRPGObject> _objectList;
	private AGRPGMap _map;
	
	public void onCreate(){
		
		_map = new AGRPGMap();
		this._map.setMapSize(10, 9, null);


		this._objectList = new ArrayList<AGRPGObject>();
		for(int index= 0; index<5;index++){
			AGRPGObject object1 = new AGRPGObject(AGModelManager.getInstance().getModel(8001));
			object1.setPosition(this._map.rcToXYCenter(0, 3 - (index - 3)));
			object1.setDirection(AGRPGObject.DIRECTION_SOUTHEAST);
			this._objectList.add(object1);
		}
		
		for(int index= 0; index<5;index++){
			AGRPGObject object1 = new AGRPGObject(AGModelManager.getInstance().getModel(8001));
			object1.setPosition(this._map.rcToXYCenter(2, 8 - index*2));
			object1.setDirection(AGRPGObject.DIRECTION_SOUTHEAST);
			this._objectList.add(object1);
		}
		
		for(int index= 0; index<5;index++){
			AGRPGObject object1 = new AGRPGObject(AGModelManager.getInstance().getModel(8001));
			object1.setPosition(this._map.rcToXYCenter(7, 8 - index*2));
			object1.setDirection(AGRPGObject.DIRECTION_NORTHWEST);
			this._objectList.add(object1);
		}
		for(int index= 0; index<5;index++){
			AGRPGObject object1 = new AGRPGObject(AGModelManager.getInstance().getModel(8001));
			object1.setPosition(this._map.rcToXYCenter(9, 3 - (index - 3)));
			object1.setDirection(AGRPGObject.DIRECTION_NORTHWEST);
			this._objectList.add(object1);
		}
	}
	
	@Override
	public void onUpdate(AGContext context){
		for(int index=0;index<this._objectList.size();index++){
			this._objectList.get(index).onUpdate(context);
		}
	}
	
	@Override
	public void onRender(AGContext context){
		this._map.onRender(context);
		for(int index=0;index<this._objectList.size();index++){
			this._objectList.get(index).onRender(context);
		}
	}
}
